
let wsMsgFromCus = function (nv, ov) {
  let source
  try {
    let pid = nv.esCompanyId;
    let aid = nv.agentID || nv.agentReads.agentId;//不同消息格式
    source = this.$store.getters.getAppInfo({
      pid: pid, aid: aid
    })
  } catch (err) {
    if (this.isDev) { console.error(err) }
  }
  if (source == null) { return }
  // 后端约定sockeyType：
  if (nv.sockeyType == 2) { //2、转发未读消息->已读的减量操作
    this.$store.commit('subUnreadAtListApp', Object.assign(
      source,
      { nUnread: nv.agentReads.readCount }
    ));
    return;
  }
  if (nv.sockeyType == 1) { // 1、广播客户消息；
    if (!nv.isFromCustomer) { return }//非客户的消息不需要增加未读数（重组存疑）
    this.$store.commit('addUnreadAtListApp', Object.assign(
      source,
      { nUnread: nv.userList.length || 1 }//后端有时单发，单发时userList会为[],
    ));
    return;
  }
  return;
};//监听来自ws消息后进行操作的部分，主要是检测来源和调用store的方法

let isSameApp = function (val) {
  let tar = this.uObjApp;
  if (tar.pid == undefined || tar.id == undefined) {
    return false;
  }
  return (tar.id == val.id) && (tar.pid == val.pid)
};


export {
  wsMsgFromCus,
  isSameApp,

}